import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/DeleteServlet")
public class DeleteServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    Integer id = Integer.valueOf(request.getParameter("id"));
    UserDao userDao = new UserDao();
    Integer result = userDao.deleteUserById(id);
    if (result  > 0 ){
        System.out.println("删除成功");
    response.sendRedirect("main");
    }else{
        System.out.println("删除失败");
        response.sendRedirect("main");
    }
}
}
